package com.fkdx.webman.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @ClassName OrderEventThreadRejected$
 * @Author wsh
 * @Description 自定义异常处理
 * @Date 16:19$ 2019/12/24$
 * @Version 1.0
 **/
public class OrderEventThreadRejected implements RejectedExecutionHandler {

    private static final Logger logger = LoggerFactory.getLogger(OrderEventThreadRejected.class);

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        ForwardingThread f = (ForwardingThread)r;
        logger.error("【 触发线程池拒绝策略, task_id: {}】", f.getId());
//        Object bean = SpringBeanUtil.getBean(f.getClassName());
//        if (bean != null && bean instanceof ICronTaskService) {
//            ICronTaskService service = (ICronTaskService) bean;
//            CronTask model = new CronTask();
//            model.setId(f.getId());
//            model.setClassParma(f.getClassParma());
//            model.setRemark("线程池超出导致任务未添加的定时器中");
//        }
    }
}
